{extend name="layout/iframe" /}

{block name="content"}
<div class="layui-card-body layui-layout-admin" style="padding: 15px;">
    <form class="layui-form" action="" lay-filter="component-form-group">
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>门店名称</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="name" maxlength="40" lay-verify="name" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>门店类型</label>
            <div class="layui-input-block">
                <select name="store_type" lay-verify="required">
                    <option value="1">自营店</option>
                    <option value="2">加盟店</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>所在城市</label>
            <div class="layui-input-block">
                <select name="region" lay-verify="required">
                    <option value="">请选择</option>
                    {foreach name="regions" item="region"}
                    <optgroup label="{$region.name}">
                        {if condition="(isset($region['child']) && $region['child'])"}
                            {foreach name="region.child" item="child"}
                                <option value="{$child.name}">{$child.name}</option>
                            {/foreach}
                        {else /}
                            <option value="{$region.name}">{$region.name}</option>
                        {/if}
                    </optgroup>
                    {/foreach}
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>门店地址</label>
            <div class="layui-input-block">
                <input type="text" id="address" class="layui-input" name="address" maxlength="60" lay-verify="required" placeholder="请输入详细地址" autocomplete="off">
                <div class="layui-form-mid layui-word-aux">(注意：此处必须是百度地图可标记的地址)</div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>地图标记</label>
            <div class="layui-input-block">
                <input type="hidden" id="address_geo" class="layui-input" name="address_geo" maxlength="60" lay-verify="address_geo" placeholder="" autocomplete="off">
                <div style="width:100%;height:300px;" id="map_container"></div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label"><span class="required">*</span>营业时间</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input start_date" name="business_start_time" lay-verify="required" placeholder="" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">至</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input end_date" name="business_end_time" lay-verify="required" placeholder="" autocomplete="off">
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>联系人</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="person" maxlength="20" lay-verify="required" placeholder="" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label"><span class="required">*</span>电话</label>
            <div class="layui-input-block">
                <input type="text" class="layui-input" name="phone" lay-verify="phone" placeholder="" autocomplete="off">
            </div>
        </div>

        <input type="hidden" name="id" value="">

        <div class="layui-form-item layui-row layui-col-xs12">
            <div class="layui-input-block">
                <div class="layui-footer">
                    <button type="button" class="layui-btn layui-btn-primary close-btn">取消</button>
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="laySave">保存 <i class="layui-icon">&#xe609;</i></button>
                </div>
            </div>
        </div>
    </form>
</div>

<input type="hidden" class="save_url" value="{:url('admin/'.strtolower($model).'/savepost')}">
{/block}

{block name="pagescript"}
<script src="https://api.map.baidu.com/api?v=2.0&ak=07E2669c3b77a0793274952ba61cd8b8&s=1" type="text/javascript"></script>
<script src="__STATIC__/admin/pages/js/store.js" type="text/javascript"></script>
<script>
    layui.use(['layer', 'laydate'], function(){
        var $ = layui.jquery,
            laydate = layui.laydate;
        // 执行一个laydate实例
        var startDate = laydate.render({
            elem: '.start_date', //指定元素
            // type: 'date',
            // format: 'yyyy-MM-dd',
            type: 'time',
            format: 'HH:mm:ss',
            trigger: 'click',
            done: function(value, date){
                //endDate.config.min.year = date.year;
                //endDate.config.min.date = date.date;

                endDate.config.min.year = date.year;
                endDate.config.min.month = date.month - 1;
                var day = date.date;
                if(date.hours == 23 && date.minutes == 59 && date.seconds == 59){
                    day = day + 1;
                }else{
                    endDate.config.min.hours = date.hours;
                    endDate.config.min.minutes = date.minutes;
                    endDate.config.min.seconds = date.seconds;
                }
                endDate.config.min.date = day;
            }
        });

        var endDate = laydate.render({
            elem: '.end_date',
            // type: 'date',
            // format: 'yyyy-MM-dd',
            type: 'time',
            format: 'HH:mm:ss',
            trigger: 'click',
            done: function(value, date){
                //startDate.config.max.year = date.year;
                //startDate.config.max.date = date.date;

                startDate.config.max.year = date.year;
                startDate.config.max.month = date.month - 1;
                var day = date.date;
                if(date.hours == 0 && date.minutes == 0 && date.seconds == 0){
                    day = day - 1;
                }else{
                    startDate.config.max.hours = date.hours;
                    startDate.config.max.minutes = date.minutes;
                    startDate.config.max.seconds = date.seconds;
                }
                startDate.config.max.date = day;
            }
        });
    });
</script>
{/block}